﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;

namespace Team4sCMDB
{
    public class AttributePanelCreator
    {
        public static Panel createPanel(DataTable dataTable)
        {
            Panel panel = new Panel();
            panel.Size = new System.Drawing.Size(100, 400);
            panel.Location = new System.Drawing.Point(500, 30);

            for (int i = 0; i < dataTable.Columns.Count; i++)
            {
                Label lbl = new Label();
                panel.Controls.Add(lbl);
                lbl.Location = new System.Drawing.Point(5, i * (2 * lbl.Size.Height + 3));
                lbl.Text = dataTable.Columns[i].ColumnName;
                TextBox tb = new TextBox();
                panel.Controls.Add(tb);
                tb.Location = new System.Drawing.Point(5, (i * (2 * lbl.Size.Height + 3)) + lbl.Size.Height + 3);
                tb.Text = dataTable.Rows[0][i].ToString();
            }
            return panel;
        }
    }
}
